<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="/WEB-INF/tld/c.tld"%>

<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML>
<html>
<head>
<base href="<%=basePath%>">
<%@include file="../common/common_ui.jsp" %>
<title>附属二级资源表</title>

<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<style type="text/css">
/* 	自动换行 */
table {word-wrap;break-word;
	word-break: break-all;
}
</style>

<script type="text/javascript">

function updateRes(id){
	window.parent.parent.sopen("<%=path%>/resourceInfo/toUpdateResourcePage.do?id="+id,"更新权限",600,550);
};

/*
* 作废角色
*/
function deleteRes(id,parentId){
	 var message = "确定作废";
	 window.parent.parent.sconfirm(message, function(){
		 $.post("<%=path%>/resourceInfo/deleteResource.do", {
             times:new Date().getTime(),
             id:id,
             parentId:parentId
             }, function() {
            	 window.parent.parent.document.getElementById("myIframe").contentWindow.loadChildPage(parentId);
     	});
	 });
};
/*
* 重启角色
*/
function restartRes(id,parentId){
	 var message = "确定重启";
	 window.parent.parent.sconfirm(message, function(){
		 $.post("<%=path%>/resourceInfo/restartResource.do", {
             times:new Date().getTime(),
             id:id,
             parentId:parentId
             }, function() {
            	window.parent.parent.document.getElementById("myIframe").contentWindow.loadChildPage(parentId);
     	});
	 });	 
};

</script>
</head>

<body>
	<div class="widget-content">
		<form id="frm" class="form-horizontal" role="form" >
		<table class="table table-striped table-bordered table-hover">
		<input type="hidden" name="parentId" id="parentId" >
			<tbody>
				<c:forEach items="${resourceInfoList}" var="resourceItem" varStatus="instatus">
					<tr>
					    <td>二级资源</td>
						<td>${instatus.index+1}</td>
						<td>${resourceItem.name}</td>
						<td>${resourceItem.url}</td>
						<td>${resourceItem.memo}</td>
						<c:if test="${resourceItem.type eq '1'}">
								<td>菜单</td>
							</c:if>
							<c:if test="${resourceItem.type eq '2'}">
								<td>按钮</td>
							</c:if>
						

						<c:if test="${resourceItem.status eq '0'}">
							<td><span class="label label-default">作废</span>
							</td>
						</c:if>
						<c:if test="${resourceItem.status eq '1'}">
							<td><span class="label label-success">有效</span>
							</td>
						</c:if>

						<c:if test="${resourceItem.status eq '1'}">
							<td>
								<button type="button" id="update" onclick="updateRes('${resourceItem.id}');"
									class="btn btn-xs btn-info">
									<span class="glyphicon  glyphicon-trash"></span>编辑
								</button>
								<button type="button" id="del" onclick="deleteRes('${resourceItem.id}','${resourceItem.parentId}');"
									class="btn btn-xs btn-danger">
									<span class="glyphicon glyphicon-pencil"></span>作废
								</button>
							</td>
						</c:if>

						<c:if test="${resourceItem.status eq '0'}">
							<td>
								<button type="button" id="restart" onclick="restartRes('${resourceItem.id}','${resourceItem.parentId}');"
									class="btn btn-xs btn-success">
									<span class="glyphicon glyphicon-ok"></span>启用
								</button>
							</td>
						</c:if>

					</tr>
				</c:forEach>
			</tbody>
		</table>
		</form>
	</div>

</body>
</html>
